from manger import db
from marshmallow import Schema, fields, post_load

class TradingCalendar(db.Model):

    __tablename__ = 'trading_calendar'
    id = db.Column(db.Integer, primary_key=True)
    trade_date = db.Column(db.Date, nullable=False)

class TradingCalendarSchema(Schema):
    class Meta:
        ordered = True
    id = fields.Integer()
    trade_date = fields.Date()
    @post_load  # 反序列化成一个对象，给schema的一个方法加上post_load装饰器
    def post_load(self, data, **kwargs):
        return TradingCalendar(**data)


